﻿
using MES.Bom.Domain;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MES.Bom.Infrastructure
{
    public class MESDBContext : DbContext
    {
        public MESDBContext(DbContextOptions options) : base(options)
        {
        }
        /// <summary>
        /// BOM表
        /// </summary>
        public DbSet<Boms> Boms { get; set; }
        /// <summary>
        /// 物料表
        /// </summary>
        public DbSet<Material> Materials { get; set; }
        /// <summary>
        /// 成品表
        /// </summary>
        public DbSet<Goods> Goods { get; set; }
        /// <summary>
        /// BOM物料中间表
        /// </summary>
        public DbSet<BomMaterial> BomMaterials { get; set; }
        /// <summary>
        /// 物料工序表
        /// </summary>
        public DbSet<MaterialProcess> MaterialProcess { get; set; }
        /// <summary>
        /// BOM工艺表
        /// </summary>
        public DbSet<BomCrafts> BomCrafts { get; set; }
        /// <summary>
        /// 迁移前表配置
        /// </summary>
        /// <param name="modelBuilder"></param>
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Boms>().HasQueryFilter(p => !p.IsDelete);
            modelBuilder.Entity<Material>().HasQueryFilter(p => !p.IsDelete);
            modelBuilder.Entity<Goods>().HasQueryFilter(p => !p.IsDelete);
            modelBuilder.Entity<BomMaterial>().HasQueryFilter(p => !p.IsDelete);
            modelBuilder.Entity<BomCrafts>().HasQueryFilter(p => !p.IsDelete);
        }
    }
}
